package com.supermarket.api.common;

/**
 * 错误信息枚举类
 * @author li
 */
public enum ErrorMessage {

    SUCCESS(0,"成功"),
    ERR_SYSTERM(1,"系统错误"),
    ERR_PARAM_ERROR(2,"参数错误"),
    ERR_TOKEN_ERROR(3,"TOKEN参数错误"),
    ERR_REFUSE_TOKEN_FAIL(4,"刷新TOKEN失败")
    ;

    private int code;
    private String message;

    ErrorMessage(int code ,String message){
        this.code = code;
        this.message = message;
    }

    // 普通方法
    public static String getName(int code,Object... args) {
        for (ErrorMessage e : ErrorMessage.values()) {
            if (e.getCode() == code){
                return String.format(e.getMessage(),args);
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}